package top.codestudy.viewtest.ui;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.target.Target;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;

import top.codestudy.viewtest.R;
import top.codestudy.viewtest.adapter.PictureAdapter;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "MainActivity";

    private SmartRefreshLayout refreshLayout;
    private RecyclerView rvImg;




    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activtity_refresh);
        refreshLayout = (SmartRefreshLayout) findViewById(R.id.refreshLayout);
        rvImg = (RecyclerView) findViewById(R.id.rv_img);
        PictureAdapter pictureAdapter = new PictureAdapter(this);
        StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(2,RecyclerView.VERTICAL);

        rvImg.setLayoutManager(staggeredGridLayoutManager);
        rvImg.setAdapter(pictureAdapter);

        refreshLayout.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshlayout) {
                refreshlayout.finishRefresh(2000/*,false*/);//传入false表示刷新失败
            }
        });
        refreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(RefreshLayout refreshlayout) {
                refreshlayout.finishLoadMore(2000/*,false*/);//传入false表示加载失败
            }
        });



    }

    public void loadImage(View view) {
//        String url = "https://www.baidu.com/img/bd_logo1.png";
//        Glide.with(this)
//                .load(url)
//                .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
//                .into(imageView);

    }


}